package com.knoya.chejian.pda.myadapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.knoya.chejian.pda.R
import com.knoya.chejian.pda.minterface.MainButtonInterface
import com.knoya.chejian.pda.module.chuku.ChukuPcodeBean
import com.knoya.chejian.pda.util.Myutil
import kotlinx.android.synthetic.main.item_guolv_weizhi.view.*

class GuolvWeizhiAdapter(private var mlist: List<String>, private val mcontext: Context,val inter : MainButtonInterface) : BaseAdapter() {
    private val minflater: LayoutInflater = LayoutInflater.from(mcontext)
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v : View
        var h : Header
        if(convertView==null){
            v=minflater.inflate(R.layout.item_guolv_weizhi,null)
            h= Header(v)
            v.tag=h
        }else{
            v=convertView
            h=v.tag as Header
        }
        Myutil.settv(mlist[position],h.Tv_Guolv_Weizhi)
        h.Bt_Weizhi_delete.setOnClickListener {
            inter.onbutton(mlist[position])
        }
        return v
    }

    override fun getItem(position: Int): Any {
        return mlist[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        return mlist.size
    }

    class Header(var v : View){
        val Tv_Guolv_Weizhi=v.Tv_Guolv_Weizhi
        val Bt_Weizhi_delete=v.Bt_Weizhi_delete
    }
}